import { useAppDispatch, useAppSelector, globalStatusAction } from '@/store';

export function useGetGlobalStatusReducer() {
  const { globalStatus } = useAppSelector(store => ({
    globalStatus: store.globalStatus,
  }));
  return globalStatus;
}
// 可下载二维码弹窗
export function useQRCodeModalDow() {
  const dispatch = useAppDispatch();
  const { qrcodeMobalDow } = useGetGlobalStatusReducer();

  function showQrcodeMobalDow() {
    dispatch(globalStatusAction.setQrcodeMobalDow(true));
  }

  function closeQrcodeMobalDow() {
    dispatch(globalStatusAction.setQrcodeMobalDow(false));
  }

  return {
    qrcodeMobalDow,
    showQrcodeMobalDow,
    closeQrcodeMobalDow,
  };
}


// 不可下载二维码弹窗
export function useQRCodeModalNDow() {
  const dispatch = useAppDispatch();
  const { qrcodeMobalNDow } = useGetGlobalStatusReducer();

  function showQrcodeMobalNDow() {
    dispatch(globalStatusAction.setQrcodeMobalNDow(true));
  }

  function closeQrcodeMobalNDow() {
    dispatch(globalStatusAction.setQrcodeMobalNDow(false));
  }

  return {
    qrcodeMobalNDow,
    showQrcodeMobalNDow,
    closeQrcodeMobalNDow,
  };
}
